package _18题;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<Product,Integer> map = new HashMap<>();

        for (int i = 0; i < 5; i++) {
            System.out.println("请输入店铺名称：");
            String store = scanner.nextLine();
            System.out.println("请输入商品名称");
            String name = scanner.nextLine();
            Product product = new Product(store,name);
            if (map.containsKey(product)){
                //商品已经存在
                Integer num = map.get(product);
                map.put(product,num+1);
            }else {
                map.put(product,1);
            }
        }

        Set<Product> products = map.keySet();
        for (Product product : products) {
            System.out.println("店铺名称："+product.getStore()+",商品名称："+product.getName()+",数量："+map.get(product));
        }

    }
}
